$(function () {
    $.ajaxSetup({
        beforeSend: function (xhr) {
            const token = localStorage.getItem("token")
            xhr.setRequestHeader("Authorization", token)
        },
        timeout: 10000,
    })
    $.ajax(`${baseUrl}/login/status`, {
        success: function (res) {
            if (res.data && res.data.isLogin) {
                window.userId = res.data.userId
            } else {
                alert("登录失败")
                location.href = "/admin/login.html"
            }
        },
        error: function (err) {
            alert("登录失效")
            location.href = "/admin/login.html"
        },
    })
})
